﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace BluetoothMachine.ValidationRules
{
    public class PortValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            int count = 0;
            if (value != null && !int.TryParse(value.ToString(), out count)) return new ValidationResult(false, "请输入正确的数字");
            if (count < 1000 || count > 65536) return new ValidationResult(false, "请输入1000-65536的数字");
            return ValidationResult.ValidResult;
        }
    }
}
